home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / MapMaster.lha / mapmaster / amosprosupport / procedures.amos / procedures.amosSourceCode < prev   
Encoding:
AMOS Source Code  |  1997-08-18  |  4.3 KB  |  94 lines

  1. Rem MapMaster V1.0 Procedures. 
  2. Rem This variable needs to be defined to hold your map 
  3. Rem Its up to you to make it large enough. eg. Dim BLOCKS(WIDTH*HEIGHT)
  4. Rem it must be global as well. 
  5. Rem For the blockcutting and pasting procedures you must have a screen opened
  6. Rem ahead of time. 
  7. Rem A width and Height of 20x12 with blocks of 16x16 will fill a normal lores screen.      
  8. Dim BLOCKS(1000)
  9. Global BLOCKS()
  10.  
  11. Rem Here is a list of things needed to use the mapfiles MapMaster
  12. Rem generates
  13. Rem A Routine to Load the map file into a array. 
  14. Rem A Routine to GetTheBlocks from a IFF file. 
  15. Rem A Routine to paste the blocks onto your screen using the map data. 
  16. Rem Well guess what I have created all these and 
  17. Rem they are here in the form of procedures for you to use.
  18.  
  19. Rem NOTE- Erase these comments when using these routines in your own code
  20.  
  21. Rem ---- A Procedure to load a Map file ------------------------------------   
  22. Rem To use this procedure just call it with the correct parameters.
  23. Rem for example _LOADMAP[df0:MAP1,10,10] will load a map off the 
  24. Rem Disk called "MAP1" and store it in the BLOCKS() array. 
  25. Rem Your program must define the BLOCK() array and make sure 
  26. Rem its large enough, like this DIM BLOCKS (X*Y #ofblocks).  
  27. Rem This variable should also be global.   
  28. Rem What do the parameters mean? 
  29. Rem _MAP$- Is a string variable with the name of the map to load 
  30. Rem _HORIZBLOCKS-  The number of Horizontalblocks in your map file.
  31. Rem _VERTBLOCKS - The number of Vertical blocks in your map file.
  32.  
  33. Procedure _LOADMAP[_MAP$,_HORIZBLOCKS,_VERTBLOCKS]
  34. Open In 1,_MAP$
  35. NUM=1
  36. Repeat 
  37. Input #1,BLOCKS(NUM)
  38. NUM=NUM+1
  39. Until NUM=_HORIZBLOCKS*_VERTBLOCKS+1
  40. Close 1
  41. End Proc
  42.  
  43. Rem --- A Procedure to Get the Blocks -------------------------------------- 
  44. Rem To use this procedure just call it with the correct parameters.  
  45. Rem For example _GETBLOCKS["df0:myblocks.iff",16,16,1] will grab 
  46. Rem the blocks off a iff called myblocks.iff and the blocks it grabs 
  47. Rem will be 16x16 pixels and it will account for a 1 pixel gap 
  48. Rem between the blocks it cuts. It will cut from the top to the bottom 
  49. Rem of the Screen and then stop. 
  50. Rem What do the parameters mean? 
  51. Rem _BLOCKSFILE$- The name of the IFF file to cut the blocks from. 
  52. Rem _BLOCKWIDTH- Width of the blocks to cut in pixels. 
  53. Rem _BLOCKHEIGHT- Height of the blocks to cut in pixels. 
  54. Rem _BLOCKGAP- Size in pixels of Gap between blocks to cut. 0=NoGap
  55.  
  56. Procedure _GETBLOCKS[_BLOCKSFILE$,_BLOCKWIDTH,_BLOCKHEIGHT,_BLOCKGAP]
  57. NUM=1 : X=_BLOCKGAP : Y=_BLOCKGAP : _TOTALWIDTH=Screen Width/(_BLOCKWIDTH+_BLOCKGAP) : WIDTH2=_TOTALWIDTH
  58. Load Iff _BLOCKSFILE$
  59. Repeat 
  60. If NUM=WIDTH2 and X+_BLOCKWIDTH>Screen Width Then X=_BLOCKGAP : Y=Y+_BLOCKHEIGHT+_BLOCKGAP : WIDTH2=WIDTH2+_TOTALWIDTH
  61. If NUM<WIDTH2 Then Get Block NUM,X,Y,_BLOCKWIDTH,_BLOCKHEIGHT,1 : X=X+_BLOCKWIDTH+_BLOCKGAP Else Get Block NUM,X,Y,_BLOCKWIDTH,_BLOCKHEIGHT,1 : X=_BLOCKGAP : Y=Y+_BLOCKHEIGHT+_BLOCKGAP : WIDTH2=WIDTH2+_TOTALWIDTH
  62. If Y+_BLOCKHEIGHT>=Screen Height Then Y=Screen Height
  63. NUM=NUM+1
  64. Until Y>=Screen Height
  65. End Proc
  66.  
  67. Rem --- A Procedure to paste the blocks to the screen ---------------------- 
  68. Rem To use this procedure you just call it with the correct values.
  69. Rem For example _PASTEBLOCKS[16,16,10,10,0,0] Will paste 16X16 sized 
  70. Rem blocks arranged in a 10x10 grid to the screen without a offset.
  71. Rem It starts pasting from coordinates 0,0 without a offset. 
  72. Rem Offsets may be minus values eg.-5    
  73. Rem What do the parameters mean? 
  74. Rem _BLOCKWIDTH- Width in pixels of your blocks
  75. Rem _BLOCKHEIGHT- Height in pixels of your blocks
  76. Rem _HORIZBLOCKS- # of horizontal blocks in your Map.  
  77. Rem _VERTBLOCKS- # of Vertical Blocks in your Map. 
  78. Rem XSET- This will offset the blocks by a given value Horizontaly 
  79. Rem       by however wide your _BLOCKWIDTH is. 
  80. Rem YSET- This will offset the blocks by a given value Verticaly 
  81. Rem       by the _BLOCKHEIGHT    
  82.  
  83. Procedure _PASTEBLOCKS[_BLOCKWIDTH,_BLOCKHEIGHT,_HORIZBLOCKS,_VERTBLOCKS,XSET,YSET]
  84. Rem /*--- Set Variables to suitable Values ---*/ 
  85. NUM=1 : X=XSET*_BLOCKWIDTH : Y=0+YSET*_BLOCKHEIGHT : NUM2=2
  86. Cls 0
  87. Repeat 
  88. Put Block BLOCKS(NUM),X,Y
  89. X=X+_BLOCKWIDTH
  90. If NUM=_HORIZBLOCKS Then Y=Y+_BLOCKHEIGHT : X=XSET*_BLOCKWIDTH
  91. If NUM=_HORIZBLOCKS*NUM2 Then Y=Y+_BLOCKHEIGHT : X=XSET*_BLOCKWIDTH : NUM2=NUM2+1
  92. NUM=NUM+1
  93. Until NUM=_HORIZBLOCKS*_VERTBLOCKS+1
  94. End Proc